/*
 * Copyright (c) 2011 Samuel Ventura All Rights Reserved
 */
package dev2net;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class Test {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException, InterruptedException {
        test2(true, true);
    }

    public static void test1(boolean com, boolean mmp) throws IOException, InterruptedException {
        Socket s = new Socket("127.0.0.1", 2011);
        OutputStream os = s.getOutputStream();
        BufferedWriter w = new BufferedWriter(new OutputStreamWriter(os));
        while (true) {
            if (com) w.write("bind com /dev/ttyS0,2201,9600,8,n,1\n");
            if (mmp) w.write("bind mmp BUZZER,10.77.0.10,2001,9\n");
            w.flush();
            Thread.sleep(3000);
        }
    }

    public static void test2(boolean com, boolean mmp) throws IOException, InterruptedException {
        while (true) {
            Socket s = new Socket("127.0.0.1", 2011);
            OutputStream os = s.getOutputStream();
            BufferedWriter w = new BufferedWriter(new OutputStreamWriter(os));
            if (com) w.write("bind com /dev/ttyS0,2201,9600,8,n,1\n");
            if (mmp) w.write("bind mmp BUZZER,10.77.0.10,2001,9\n");
            w.flush();
            s.close();
            Thread.sleep(3000);
        }
    }
}
